package com.whmskj.xjlhbc.domain;

import cn.hutool.core.date.BetweenFormatter;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

@Data
@Schema(name = "故障维修请求响应参数",description = "故障维修请求响应参数")
@TableName(value = "schedulingOfSbbx01MalfunctionRep",autoResultMap = true)
public class SchedulingOfSbbx01MalfunctionRep {
    @TableId(type = IdType.AUTO)
    private Integer id;

    private String itsARepairOrder;

    @Schema(description = "机台号")
    private String deviceNumber;

    @Schema(description = "故障原因")
    private String analysisOfTheCauseOfTheFailure;

    private Long numberOfMalfunctioningEquipment;

    private Long timeOut;

    private Date timeOut1;

    private String levelOfUrgency;

    private String revealer;

    private Date timeOfSubmission;

    private String deviceName;

    private String f444;

    @Schema(description = "故障类型")
    private String faultType;

    private Date renovationTime;

    @Schema(description = "设备名称")
    private String deviceInformation;

    @Schema(description = "状态")
    private String maintenanceStatus;

    private String maintainer;

    private Date startOfMaintenance;

    private Date completionOfMaintenance;

    @Schema(description = "维修耗时")
    private String maintenanceTime;

    private BigDecimal maintenanceCosts;

    private Date timeOfSubmission1;

    private Integer f6f1;

    private String theWarranty;

    private Date timeOfSubmissionOfWarranties;

    private Date f9ba;

    private String maintenanceResultsForTheAuthor;

    private Long serialNumber;

    private String equipment;

    private String deviceNamenumber;

    @Schema(description = "维修日期")
    private String maintenanceDate;

    @Schema(description = "维修人")
    private String fb02;

    @TableField(exist = false)
    @Schema(description = "职务")
    private String typeOfEmployment;

    private String theAuthor;

    @Schema(description = "操作人")
    private String operator;

    @Schema(description = "操作时间")
    private String operationTime;

    @Schema(description = "处理措施")
    private String measuresToAddressThem;

    @Schema(description = "更换备件记录")
    private String replacementOfSpareParts;

    @Schema(description = "备注")
    private String remarks;

    @TableField(typeHandler = JacksonTypeHandler.class)
    @Schema(description = "故障图片")
    private List<Object> badPhotos = new ArrayList<>();

    @Schema(description = "车间")
    private String workshop;

    @TableField(exist = false)
    @Schema(description = "更换配件")
    private List<ReplaceAccessories> replaceAccessoriesList = new ArrayList<>();

    @Schema(description = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date otherOrganiser;

    @Schema(description = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date endTime;

    public String getMaintenanceTime(){
        if(Objects.nonNull(otherOrganiser) && Objects.nonNull(endTime)){
            return DateUtil.formatBetween(otherOrganiser, endTime, BetweenFormatter.Level.SECOND);
        }
        return null;
    }
}
